<template>
	<view class="containerbox">
		<uv-navbar title="体验课" placeholder>
			<template v-slot:left>
				<uv-icon name="home" v-if="sceneVal" size="20" @click="gohomeEvent"></uv-icon>
				<uv-icon name="arrow-left" v-else size="20" @click="backEvent"></uv-icon>
			</template>
		</uv-navbar>
		<scroll-view scrollY class="containerbox">
			<view class="container">
				<mp-html :content="detail.introduction" />
			</view>
		</scroll-view>
		<view class="px-24 py-10 flex items-center justify-between">
			<button class="btn btn1" open-type="share">分享好友</button>
			<button @click="submit" class="btn btn2">立即购买</button>
		</view>
	</view>
</template>

<script setup lang="ts">
import { reactive, ref } from 'vue';
import { product_api, suborder_api } from '@/common/apis/other'
import { onShow, onLoad, onShareAppMessage } from "@dcloudio/uni-app"

const trialDatetimePicker = ref()

const formdata = reactive({
	name: '',
	mobile: '',
	grade: '',
	score: '',
	datetime: ''
})

const detail = ref({})
const sceneVal = ref(false)
const agentId = ref()
onLoad(async (o) => {
	console.log('页面中接收的参数：',o)
	if(o.scene){
		sceneVal.value = true
		const regex = /agentId_(\d+)/;  
		const match = o.scene.match(regex);  
		agentId.value = match[0]
	}
	if(o.agentId){
		sceneVal.value = true
		agentId.value = o.agentId
	}
	// 体验课固定传11
	detail.value = await product_api({id: 11})
})

function submit(){
	uni.navigateTo({
		url: '/pages/other/special/payment?id=11' + (agentId.value ? ('&agentId='+ agentId.value) : '')
	})
}

function backEvent(){
	uni.navigateBack()
}

function gohomeEvent(){
	uni.switchTab({
		url: '/pages/tabbar/home/index'
	})
}

</script>

<style lang="scss" scoped>
.btn{width: 310rpx; height: 96rpx; line-height: 96rpx; text-align: center; color: #fff; border-radius: 20rpx;}
.btn1{background-color: #F69B2C;}
.btn2{background-color: #0B9AFF;}
</style>	